<?php
namespace app\common\model;
/**
 * Created by PhpStorm.
 * User: junyv
 * Date: 2016/9/18
 * Time: 10:36
 */
use traits\model\SoftDelete;
class Article extends \think\Model
{
    use SoftDelete;  //软删除
    protected $deleteTime = 'delete_time';
    protected $autoWriteTimestamp = true;
    //protected $createTime = 'add_time'; 指定时间字段
   // protected $updateTime = 'update_time';
   /* protected $type = [
        'file'    =>  'serialize'
    ];*/
    public function articleCate(){
        return $this->hasOne('article_cate','id','cate_id',[],'left');
    }

    protected function setTagsAttr($value){
        return str_replace('，',',',$value);
    }
    protected function setInfoAttr($value){
        $replace = cache('keyword');
        if($replace){
            $tmp = [];
            foreach($replace as $v){
                $tmp[$v['word']] = $v['url'] ? '<a href="'.$v['url'].'" target="_blank" >'.$v['replace_word'].'</a>' : $v['replace_word'];
            }
            if($tmp){
                return strtr($value,$tmp);
            }
        }
        return $value;
    }
}